package models;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;

/**
 * Created by xieyicheng on 2015/1/22.
 */
@Entity
@Table(name = "trend")
public class Trend  extends BasicModel {

    //行为
    public final static int ARTICLE=1;
    public final static int ALBUM=0;

    // 动态所有人的id
    @Column(name = "owner_id")
    public String owner_id;

    // 动态的对象的id
    @Column(name = "object_id")
    public String object_id;

    // 动态类型
    @Column(name = "type")
    public int type;
    
    public static void addTrend(String owner_id,String object_id,int type)
    {
    	Trend trend = new Trend();
    	trend.object_id = object_id;
    	trend.owner_id = owner_id;
    	trend.type = type;
    	trend.save();
    }
    
    public static void deleteTrend(String object_id,int type)
    {
    	Trend trend = Trend.find("object_id = ? and type = ?", object_id,type).first();
    	if(trend != null)
    		trend.delete();
    }

}
